#ifndef PLOT_H
#define PLOT_H

#include <qwt_plot.h>
#include <QMouseEvent>
#include "datacurve.h"
class QwtPlotDirectPainter;
class QwtPlotPanner;
class QwtPlotMagnifier;
class QwtPlotZoomer;
class Plot : public QwtPlot
{
	Q_OBJECT

public:
	Plot(QWidget *parent);
	~Plot();
	void updateXAxisWidth(double width);
	void plot(int t, double y,int feq);
	void autoScale();
	double x(int idx){ return data_curve->dataPoint(idx).x(); }
	double y(int idx){ return data_curve->dataPoint(idx).y(); }
	int dataLength(){ return data_curve->dataLength(); }
	void setKeyZoomer();
	void setWheelZoomer();
	void initZoomer();
	void mouseDoubleClickEvent(QMouseEvent *e);
signals:
	void maximize(Plot* p);
private:
	void updateXAxis();
	void resetXAxis();
	QwtInterval x_interval;
	QwtInterval y_interval;
	DataCurve* data_curve;
	QwtPlotDirectPainter *direct_painter;
	QwtPlotPanner* panner;
	QwtPlotMagnifier* magnifier;
	QwtPlotZoomer* zoomer;
	int interval_point_num;
	int interval_point_total;
	int last_t; 
	int last_feq; 
};

#endif // PLOT_H
